package com.test1;

import java.io.File;

/**
 * @Auther: ChenJinEn
 * @Date: 2020/7/27 16:09
 * @Description: //TODO
 */
public class SearchFile {

    public static void main(String[] args) {
        findFile(new File("D:\\迅雷下载"),".mp4");
    }

    //文件搜索
    private static void findFile(File file,String name) {
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isDirectory()) {
                findFile(file1,name);//是文件夹就继续递归遍历
            }else {
                String file1Name = file1.getName();
                if (file1Name.endsWith(name)) {
                    System.out.println(file1);
                }
            }
        }
    }

}
